Package com.cisco.pt.mu
package com.cisco.pt.mu
This framework also includes the capability to connect to Packet Tracer using the Multiuser feature.
This feature is strictly to capture from and send packets to Packet Tracer. All instances of packets
from PT will inherit the Signal class, which inherits IPCData. So all packets are IPCData objects in the
top level. To connect to the Packet Tracer using Multiuser, it is similar to the IPC. Take the following code
for example:
int linkId = 0;
PacketTracerSessionFactory packetTracerMUSessionFactory = PacketTracerMUSessionFactoryImpl.getInstance();
ConnectionNegotiationProperties cnpmu = OptionsManager.getInstance().getConnectOpts();
cnpmu.setAuthenticationApplication(user);
cnpmu.setAuthenticationSecret(pass);
cnpmu.setReserved("7.0");
packetTracerMUSession = packetTracerMUSessionFactory.openSession(
localhost, 38000, cnpmu);
if (packetTracerMUSession.isConnected()){
((MUSessionImpl) packetTracerMUSession)
.registerEventManager(new PTBMuEventManager(this) {
public void handlePdu(MUPDUMessage pdu) {
System.out.println("received pdu");
}
});
try {
if (((MUSessionImpl) packetTracerMUSession)
.getAvailableLinkCount() > 0) {
MULink info;
info = ((MUSessionImpl) packetTracerMUSession).getLinkAt(0);
MULink newlink = new MULink();
newlink.linkId = linkId; // We connect to the first available link
newlink.localPortId = -1;
newlink.localCableType = info.remoteCableType;
newlink.localPortName = "FastEthernet" + ifname;
newlink.localPortType = info.remotePortType;
newlink.localPortPower = info.remotePortPower;
newlink.localStraightPins = info.remoteStraightPins;
newlink.localAutoCross = info.remoteAutoCross;
newlink.localBandwidth = info.remoteBandwidth;
newlink.localFullDuplex = info.remoteFullDuplex;
newlink.localAutoNego = info.remoteAutoNego;
newlink.localBWNego = info.remoteBWNego;
newlink.localDuplexNego = info.remoteDuplexNego;
newlink.localClockRate = info.remoteClockRate;
newlink.localDcePort = !info.remoteDcePort;
newlink.linkUuid = info.linkUuid;
newlink.localDeviceType = 8; // pc
((MUSessionImpl) packetTracerMUSession).updateLink(newlink);
} else {
MULink newlink = new MULink();
newlink.linkId = linkId; // Connect to link 0 since it is the only link.
newlink.localPortId = -1;
newlink.localCableType = CableType.CABLE_TYPE_COPPER_CROSS_OVER
.getIntValue();
newlink.localPortName = "FastEthernet" + ifname;
newlink.localPortType = PortType.COPPER_FAST_ETHERNET
.getIntValue();
newlink.localPortPower = true;
newlink.localStraightPins = false;
newlink.localAutoCross = true;
newlink.localBandwidth = 100000;
newlink.localFullDuplex = true;
newlink.localAutoNego = false;
newlink.localBWNego = false;
newlink.localDuplexNego = false;
newlink.localClockRate = 400000;
newlink.localDcePort = false;
newlink.localDeviceType = 8; // pc
((MUSessionImpl) packetTracerMUSession).addLink(newlink);
}
} catch (Exception e) {
e.printStackTrace();
}
The above code connects to Packet Tracer's Multiuser cloud and registers for listening to PDU's. There
is a single handlePdu function which contains a PDU event message. This message also contains the PDU
data itself. Once registered, it then attempts to check if any ports are available on the multiuser
cloud from PT. If there are any links, it connects to the first available link. If there are no links,
it creates a link to PT.- Version:
- 7.0.0
- Author:
- Tony Deng
-
ClassDescriptionThis is a name update message from PT.This is a name update message from PT.A class that represents a MultiUser Link (either remote or local)This is a name update message from PT.This is a name update message from PT.Base class for all Multi User MessagesThis is a name update message from PT.This is the first message sent by the MU protocol.This is a PDU message from PT.This is a port advertisement message from PT.This is a save network request message from PT.This is a save network request message from PT.This is a data class that contains port information elements from the Port Advertisement Messages.This class defines data for the Save request message.